< previous page page_544 next page >

Page 544
Next, the routine uses the IsAbove function to see if the second face is completely above the plane containing the first face. If it is, the first face cannot block the view of the second from the center of projection. Once again the subroutine does not need to move the second face to the front of the list.
Similarly, the routine uses the IsBelow function to see if the first face is completely below the plane that contains the second. If so, the first face cannot block the view of the second from the center of projection, so the subroutine does not need to rearrange the faces.
Any of these tests might determine that the faces do not overlap, but none can conclude that they do. In the final test, SortFaces uses the function Obscures to attempt to determine whether the first face really does block the view of the second from the center of projection.
The following code shows the SortFaces subroutine. The IsAbove and Obscures functions are listed and described in more detail in the following sections.
e10a6a0a59f035e870d90cca05b85fce.gif
' Sort the faces so those with the largest
' transformed Z coordinates come first.
'
' As we switch faces around, we keep track of the
' number of switches we have made. If it's clear we
' are stuck in an infinite loop, just move the
' first face to the ordered_faces collection so we
' can continue.
Public Sub SortFaces()
Dim ordered_faces As Collection
Dim face_1 As Face3d
Dim face_i As Face3d
Dim i As Integer
Dim Xmin As Single
Dim xmax As Single
Dim ymin As Single
Dim ymax As Single
Dim zmin As Single
Dim zmax As Single
Dim xmini As Single
Dim xmaxi As Single
Dim ymini As Single
Dim ymaxi As Single
Dim zmini As Single
Dim zmaxi As Single
Dim overlap As Boolean
Dim switches As Integer
Dim max_switches As Integer

    Set ordered_faces = New Collection 

    ' Pull out any that are culled. These are not
    ' drawn so we can put them at the front of

 
< previous page page_544 next page >